﻿using System.Collections;
using System.Collections.Generic;
using Hazza.UserInput.Models;
using Orchard;
using Orchard.Data;

namespace Hazza.UserInput.Services
{
    public interface IUserInputService : IDependency
    {

    }

    public class UserInputService : IUserInputService {
        private readonly IRepository<InputRecord> inputRepository;
        public UserInputService(IRepository<InputRecord> inputRepository) {
            this.inputRepository = inputRepository;
        }

        public IEnumerable<int> AddAll(IEnumerable<InputRecord> records) {
            foreach (var record in records) {
                Add(record);
                yield return record.Id;
            }
        }

        public int Add(InputRecord record) {
            inputRepository.Create(record);
            return record.Id;
        }
    }
}